import 'package:flutter/material.dart';
import 'package:hzy_normal_tool/hzy_normal_tool.dart';

import '../../widgets/index.dart';
import 'base_getx_controller.dart';

import 'package:get/get.dart';

abstract class BaseGetXV<T extends BaseGetXController> extends GetView<T>
    with HzyScaffolMixin, HzyAppBarMixin, HzyBodyMixin, HzyAbsAttribute {
  BaseGetXV({super.key});

  @override
  Widget build(BuildContext context) {
    Widget body = createBuild(
      context: context,
    );
    return body;
  }

  @override
  Widget createBuild({
    required BuildContext context,
  }) {
    return Obx(
      () => createScaffolWidget(context: context),
    );
  }

  @override
  createLoadingWidget() {
    return configLoadWidget();
  }

  @override
  Widget? createEmptyWidget() {
    return PlaceHoldPage(
      placeHoldType: controller.placeHoldType,
      msg: controller.placeMsg,
      btnMsg: controller.placeBtnMsg,
      onTap: () {
        controller.tapPlaceHoldWidgetMethod(
          placeHoldType: controller.placeHoldType,
        );
      },
    );
  }

  /// UI配置项
  ///
  ///

  /// ---------------- 脚手架配置项 ---------------- ///
  /// 是否使用脚手架
  @override
  bool configIsNeedScaffol() {
    return controller.isNeedScaffol;
  }

  ///是否形变
  @override
  bool? configResizeToAvoidBottomInset() {
    return controller.resizeToAvoidBottomInset;
  }

  /// 脚手架背景颜色
  @override
  Color? configScallBackgroundColor() {
    return controller.scallBackGroundColor;
  }

  /// ---------------- AppBar配置项 ---------------- ///

  /// 是否需要导航栏
  @override
  bool configIsShowAppBar() {
    return controller.isShowAppBar;
  }

  @override
  configleadingCallbak({
    BuildContext? context,
  }) {
    controller.tapNormalBack();
  }

  /// 配置导航栏标题
  @override
  String? createAppBarTitleStr() {
    return controller.appBarTitle;
  }

  /// 配置导航栏背景颜色
  @override
  Color? createAppBarNavBackColor() {
    return controller.navBackgroudColor;
  }

  /// 配置导航栏背景视图
  @override
  Widget? createFlexBleSpace() {
    return null;
  }

  /// ---------------- 安全区域配置项 ---------------- ///
  /// 是否需要 安全区域 控件
  @override
  bool configIsNeedSafeArea() {
    return controller.isNeedSafe;
  }

  /// 是否关闭顶部安全区域
  @override
  bool configSafeAreaTop() {
    return controller.safeAreatop;
  }

  /// 是否关闭底部安全区域
  @override
  bool configSafeAreaBottom() {
    return controller.safeAreabottm;
  }

  /// ---------------- 界面通用配置项 ---------------- ///
  /// 是否显示加载动画
  @override
  bool configIsshowLoading() {
    return controller.isShowLoadWidget.value;
  }

  @override
  bool configIsNeedPlaceHolder() {
    return controller.isNeedPlaceHolder;
  }

  /// 配置界面状态值
  @override
  configPageState() {
    return controller.pageState.value;
  }
}
